// src/router/index.js
//第五步更新路由配置
import { createRouter, createWebHistory } from 'vue-router';

// 导入组件 - 使用动态导入避免循环依赖
const Layout = () => import('@/components/Layout.vue');
const DashboardView = () => import('@/views/DashboardView.vue');
const CourseListView = () => import('@/views/CourseListView.vue');
const LoginView = () => import('@/components/LoginView.vue');

const routes = [
  {
    path: '/login',
    name: 'Login',
    component: LoginView,
    meta: { requiresAuth: false }
  },
  // 在router/index.js中添加
{
  path: '/diagnostic',
  name: 'Diagnostic',
  component: () => import('@/views/DiagnosticView.vue')
},
// src/router/index.js
// 在routes数组中添加：
{
  path: '/courses/debug',
  name: 'CoursesDebug',
  component: () => import('@/views/CourseDebugView.vue')
},
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    meta: { requiresAuth: true },
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: DashboardView
      },
      {
        path: 'courses',
        name: 'Courses',
        component: CourseListView
      },
      // src/router/index.js
// 在routes数组中添加用户管理路由
{
  path: '/users',
  name: 'Users',
  component: () => import('@/views/UserListView.vue'),
  meta: { requiresAuth: true }
},
// src/router/index.js
// 在routes数组中添加学生选课路由
{
  path: '/course-selection',
  name: 'CourseSelection',
  component: () => import('@/views/CourseSelectionView.vue'),
  meta: { requiresAuth: true, requiredRole: 'student' }
},
// 在routes数组中添加通知公告路由
{
  path: '/notices',
  name: 'Notices',
  component: () => import('@/views/NoticeListView.vue'),
  meta: { requiresAuth: true }
}
      // 可以继续添加其他路由
    ]
  }
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

// 简单的路由守卫 - 先注释掉复杂的逻辑
router.beforeEach((to, from, next) => {
  console.log('路由导航:', from.path, '->', to.path);
  next(); // 确保导航继续
});

export default router;